﻿using System;

namespace Cpu6502.Opcodes
{
    /// <summary>
    /// STY $AAAA - Store Register Y Absolute Mode
    /// Stores Register Y in memory address
    /// </summary>
    class STY_A : Opcode
    {
        public STY_A()
        {
            this.CpuCycles = 4;
            this.AddressType = CPU.AddressType.Absolute;
        }

        public override void Execute()
        {
            CPU.Memory[base.Argument] = CPU.Registers.Y;
        }
    }


    /// <summary>
    /// STY $AA - Store Register Y Zeropage Mode
    /// Stores Register Y in memory address
    /// </summary>
    class STY_ZP : Opcode
    {
        public STY_ZP()
        {
            this.CpuCycles = 3;
            this.AddressType = CPU.AddressType.ZeroPage;
        }

        public override void Execute()
        {
            CPU.Memory
                [
                    MemoryHelper.GetAddress
                    (base.Argument, CPU.AddressType.ZeroPage)
                ] = CPU.Registers.Y;
        }
    }

    /// <summary>
    /// STY $AA, X - Store Register Y Zeropage X Mode
    /// Stores Register Y in memory address
    /// </summary>
    class STY_ZP_X : Opcode
    {
        public STY_ZP_X()
        {
            this.CpuCycles = 4;
            this.AddressType = CPU.AddressType.ZeroPageIndexedX;
        }

        public override void Execute()
        {
            CPU.Memory
                [
                    MemoryHelper.GetAddress
                    (base.Argument, CPU.AddressType.ZeroPageIndexedX)
                ] = CPU.Registers.Y;
        }
    }
}